<template>
  <div>
    <van-pull-refresh v-model="RefreshThe" @refresh="onRefresh">
      <van-list v-model="loading" :finished="finished" finished-text="--没有更多了--" @load="onLoad">
        <div v-for="item in list" :key="item" >{{ item }}</div>
      </van-list>

    </van-pull-refresh>

  </div>
</template>

<script>
export default {
  data() {
    return {
      list: [],
      loading: false, // 控制是否在加载中
      finished: false, // 控制是否加载完成
      RefreshThe: false, // 控制是否在刷新中...
    };
  },
  methods: {
    onLoad() {
        // 默认会加载一次
        console.log('onLoad加载')
        //   正在刷新中则把数据清空
        if (this.RefreshThe) {
          this.list = [];
          this.RefreshThe = false;
        }

        for (let i = 0; i < 10; i++) {
          this.list.push(this.list.length + 1);
        }
        this.loading = true;
    },
    onRefresh() {
      // 清空列表数据
      this.finished = false;
      // 重新加载数据
      // 将 loading 设置为 true，表示处于加载状态
      this.loading = true;
      this.onLoad();
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
